{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c93595c3-224f-4122-9fef-eb73cbdd3a14",
   "metadata": {},
   "source": [
    "# Dual-Axis Time-Series Plot\n",
    "\n",
    "A plot showing two time-series with different value ranges on separate y-axes. This is helpful when visualizing two related variables that have different units or scales.\n",
    "\n",
    "Dual/twin axis is enabled with the `multi_y` plotting option made available by HoloViews (follow [this issue](https://github.com/holoviz/hvplot/issues/1133) to track its implementation in hvPlot directly). It is only supported by the Bokeh backend."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5808060b-7c5e-4e01-960f-5bec33cd9f59",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import hvplot.pandas  # noqa\n",
    "\n",
    "np.random.seed(0)\n",
    "dates = pd.date_range(\"2024-01-01\", periods=30, freq=\"D\")\n",
    "df = pd.DataFrame({\n",
    "    'temperature': np.random.normal(25, 2, size=30),\n",
    "    'humidity': np.random.uniform(60, 90, size=30)\n",
    "}, index=dates)\n",
    "\n",
    "temp = df.hvplot.line(y='temperature', ylabel='Temperature (°C)', label='Temperature')\n",
    "humid = df.hvplot.line(y='humidity', ylabel='Humidity (%)', label='Humidity', color='green')\n",
    "\n",
    "# Overlay with dual axes using multi_y option (only in Bokeh)\n",
    "dual = (temp * humid).opts(multi_y=True, title=\"Temperature vs Humidity (Bokeh)\")\n",
    "dual"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c9cf8c5a-1473-4f87-a2c9-30c4c845f71a",
   "metadata": {},
   "source": [
    ":::{seealso}\n",
    "- [Line plot reference documentation](../../ref/api/manual/hvplot.hvPlot.line.ipynb)\n",
    "- [HoloViews Customizing Plots guide](https://holoviews.org/user_guide/Customizing_Plots.html#twin-axes).\n",
    ":::"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
